package com.cssl.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cssl.pojo.Decruitment;
import com.cssl.pojo.Rewards;
import com.cssl.serice.RewardsSerice;
import com.cssl.serice.impl.RewardsImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RestController
public class RewardsController {

    @Resource
    private RewardsSerice rewards;

    //奖惩制度的查询 奖查询
    @RequestMapping("/rewards")
    public IPage<Rewards> rewards(String code,String dname,String rewardsdate,Integer pageIndex, Integer pageSize){
        if (pageIndex ==null){
            pageIndex =1;
        }
        pageSize =2;
        IPage<Rewards> page=rewards.rewardsquery(new Page<Rewards>(pageIndex,pageSize),new QueryWrapper<Rewards>()
                .like(dname !=null,"d.dname",dname).like(code !=null,"s.code",code)
                .like(rewardsdate !=null,"r.rewardsdate",rewardsdate).eq("r.rtype",0));
        return  page;
    }

   //惩的查询
    @RequestMapping("/rewards2")
    public IPage<Rewards> rewards2(String code,String dname,String rewardsdate,Integer pageIndex, Integer pageSize){
        if (pageIndex ==null){
            pageIndex =1;
        }
        pageSize =2;
        IPage<Rewards> page=rewards.rewardsquery(new Page<Rewards>(pageIndex,pageSize),new QueryWrapper<Rewards>()
                .like(dname !=null,"d.dname",dname).like(code !=null,"s.code",code)
                .like(rewardsdate !=null,"r.rewardsdate",rewardsdate).eq("r.rtype",1));
        return  page;
    }

    //添加的选择员工

    //添加


    //修改员工的前查询
    //也可以是统计报表
    @RequestMapping("/rewardsselect")
    public List<Rewards> rewardsselect(Integer id, String rewardsdate){

        List<Rewards>  ll=rewards.rewardsselect(new QueryWrapper<Rewards>()
                .eq( id !=null && id != 0,"r.id",id)
                .like(rewardsdate != null,"r.rewardsdate",rewardsdate));
        return ll;
    }

    //修改


    //删除
    @RequestMapping("/rewardelete")
    public boolean rewardelete(int id){
        return  rewards.removeById(id);
    }








}
